home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16590 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  54 lines

  1. Path: news.dpi.udec.cl!tarmstro
  2. From: tarmstro@caleuche.inf.UDEC.CL (Thomas Armstrong Kobrich)
  3. Newsgroups: comp.lang.c++
  4. Subject: Array of Funcions ??
  5. Date: 10 Apr 1996 17:27:40 GMT
  6. Organization: Universidad de Concepcion, Concepcion - Chile
  7. Message-ID: <4kgr2c$b99@news.dpi.udec.cl>
  8. NNTP-Posting-Host: caleuche.inf.udec.cl
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11.     Hi there:
  12.  
  13.     I've the following problem. I Want to define an array
  14. of functions (all with the same return value an the same parameters,
  15. of course), named FuncArray, but I'dont know how to do it.
  16.     The sentence:
  17.  
  18.         static void (Func)(void);
  19.  
  20.     declares a variable named Func, that is a pointer to a 
  21. function with prorotype of the form
  22.  
  23.         void foo(void);
  24.  
  25.     This way, it is legal to write the following:
  26.  
  27.         void foo2(void)
  28.         {  ....  }
  29.  
  30.         static void (Func)(void);
  31.  
  32.         int main(void)
  33.         {
  34.            Func=foo2;
  35.            ...
  36.            Func();   /* calls foo2() in fact */
  37.            ...
  38.         }
  39.  
  40.     I want to declare an array of funcions so I can write
  41.  
  42.         for(i=0; i<MAX; i++)
  43.           (Func[i])();
  44.  
  45.     or somthing like that.
  46.  
  47.     Help would be wery appreciated.  Thanx.
  48.  
  49. --
  50. ------------------------------------------------------------------
  51. | Thomas Armstrong Kobrich    |   tarmstro@caleuche.inf.udec.cl  |
  52. |    Concepcion - Chile       |     Universidad de Concepcion    |
  53. ------------------------------------------------------------------
  54.